<template>
    <n-config-provider
        preflight-style-disabled
        :locale="zhCN"
        :date-locale="dateZhCN"
        :theme="themed"
    >
        <n-global-style />
        <n-dialog-provider>
            <n-message-provider>
                <router-view />
            </n-message-provider>
        </n-dialog-provider>
    </n-config-provider>
</template>

<script setup lang="ts">
import { useGlobalStore } from '@/store'
import { onMounted } from 'vue'
import Logo from '@/assets/vue.svg'
import { dateZhCN, zhCN } from 'naive-ui'
import { storeToRefs } from 'pinia'

const globalStore = useGlobalStore()
const { themed } = storeToRefs(globalStore)

onMounted(() => {
    // 注入css变量
    globalStore.setCssVars()

    // 修改页面标题
    document.title = import.meta.env.VITE_APP_NAME

    // 修改 favicon
    const favicon: HTMLElement | null = document.getElementById('favicon')
    if (favicon) {
        ;(<HTMLLinkElement>favicon).href = Logo
    }
})
</script>
